import random
import time

class TimeSpeed:
    def __init__(self):
        self.start = time.time()

    def __enter__(self):
        print("啦啦啦啦")
        # time.sleep(1)
        self.l = l.sort()

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.end = time.time()
        print(f"花费时间{self.end-self.start}")


l = [random.randint(1,100) for i in range(10000)]

with TimeSpeed() as ts:
    pass

